package com.bw.controller;

import com.bw.been.Sugar;
import com.bw.been.SugarFour;
import com.bw.been.SugarThree;
import com.bw.been.SugarTwo;
import com.bw.service.SugarService;
import com.sugar.SugarUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
public class SugarController {

    @Autowired
    SugarService sugarService;

    @RequestMapping("getList1")
    public Map getList1(){
        List<Sugar> list = sugarService.getList1();
        Map map = SugarUtil.getSummaryData(list);
        return map;
    }

    @RequestMapping("getList2")
    public Map getList2(){
        List<Sugar> list = sugarService.getList2();
        Map map = SugarUtil.getPieData(list);
        return map;
    }

    @RequestMapping("getList3")
    public Map getList3(){
        List<Sugar> list = sugarService.getList3();
        Map map = SugarUtil.getLineData(list);
        return map;
    }

    @RequestMapping("getList4")
    public Map getList4(){
        List<SugarTwo> list = sugarService.getList4();
        List<String> list1 = new ArrayList<>();
        list1.add("课程名称");
        list1.add("考试人次");
        list1.add("平均分");
        list1.add("平均用时");
        Map map = SugarUtil.getTablePlayData(list1,list);
        return map;
    }

    @RequestMapping("getList5")
    public Map getList5(){
        Double val = sugarService.getList5();
        Map map = SugarUtil.getFlipNumberData(val);
        return map;
    }

    @RequestMapping("getList6")
    public Map getList6(){
        List<Sugar> list = sugarService.getList6();
        Map map = SugarUtil.getBarData(list);
        return map;
    }

    @RequestMapping("getList7")
    public Map getList7(){
        List<SugarThree> list = sugarService.getList7();
        List<String> list1 = new ArrayList<>();
        list1.add("店铺类型:1.直营 2.加盟");
        list1.add("下单金额");
        list1.add("下单次数");
        list1.add("下单人数");
        list1.add("实收金额");
        list1.add("退款成功金额");
        Map map = SugarUtil.getTablePlayData(list1,list);
        return map;
    }

    @RequestMapping("getList8")
    public Map getList8(){
        List<SugarFour> list = sugarService.getList8();
        List<String> list1 = new ArrayList<>();
        list1.add("店铺名称");
        list1.add("下单活动减免金额");
        list1.add("排名");
        Map map = SugarUtil.getTablePlayData(list1,list);
        return map;
    }
}
